<?php
// +----------------------------------------------------------------------
// | RXThinkCMF框架 [ RXThinkCMF ]
// +----------------------------------------------------------------------
// | 版权所有 2017~2020 南京RXThinkCMF研发中心
// +----------------------------------------------------------------------
// | 官方网站: http://www.rxthink.cn
// +----------------------------------------------------------------------
// | Author: 牧羊人 <1175401194@qq.com>
// +----------------------------------------------------------------------

namespace app\controller;

use app\service\MenuService;
use app\service\UserService;
use think\App;

/**
 * 系统主页-控制器
 * @author 牧羊人
 * @since 2020/11/14
 * Class Index
 * @package app\controller
 */
class Index extends Backend
{
    /**
     * 构造函数
     * @param App $app
     * @since 2020/11/14
     * Index constructor.
     * @author 牧羊人
     */
    public function __construct(App $app)
    {
        parent::__construct($app);
    }

    /**
     * 获取菜单列表
     * @author 牧羊人
     * @since 2020/11/14
     */
    public function getMenuList()
    {
        $menuService = new MenuService();
        $result = $menuService->getPermissionList($this->userId);
        return $result;
    }

    /**
     * 获取用户信息
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @since 2020/11/20
     * @author 牧羊人
     */
    public function getUserInfo()
    {
        $userService = new UserService();
        $result = $userService->getUserInfo($this->userId);
        return $result;
    }

    /**
     * 更新个人资料
     * @return mixed
     * @since 2020/11/11
     * @author 牧羊人
     */
    public function updateUserInfo()
    {
        $userService = new UserService();
        $result = $userService->updateUserInfo();
        return $result;
    }

    /**
     * 更新密码
     * @return array
     * @throws \think\db\exception\BindParamException
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @author 牧羊人
     * @since 2020/11/15
     */
    public function updatePwd()
    {
        $userService = new UserService();
        $result = $userService->updatePwd($this->userId);
        return $result;
    }

}